package com.gxc.blogm.service;

import com.gxc.blogm.util.Cache;

public class CacheService {

	private BulletinService bulletinService;

	private ArticleService articleService;
	
	private FrendlinkService frendlinkService;

	public BulletinService getBulletinService() {
		return bulletinService;
	}

	public void setBulletinService(BulletinService bulletinService) {
		this.bulletinService = bulletinService;
	}

	public ArticleService getArticleService() {
		return articleService;
	}

	public void setArticleService(ArticleService articleService) {
		this.articleService = articleService;
	}

	public FrendlinkService getFrendlinkService() {
		return frendlinkService;
	}

	public void setFrendlinkService(FrendlinkService frendlinkService) {
		this.frendlinkService = frendlinkService;
	}

	/**
	 * 更新缓存
	 */
	public void reload() {
		this.reloadBulletin();
		this.reloadArticleSortList();
		this.reloadArticleArchiveList();
		this.reloadFrendlinkList();
	}

	/**
	 * 更新最新公告缓存
	 */
	public void reloadBulletin() {
		Cache.bulletin = bulletinService.retrieveLatest();
	}

	/**
	 * 更新文章分类统计缓存
	 */
	public void reloadArticleSortList() {
		Cache.articleSortList = articleService.statByType();
	}

	/**
	 * 更新文章按月统计缓存
	 */
	public void reloadArticleArchiveList() {
		Cache.articleArchiveList = articleService.statByYearMonth();
	}

	/**
	 * 更新友情链接缓存
	 */
	public void reloadFrendlinkList() {
		Cache.frendlinkList =  frendlinkService.retrieveLatest();
	}

}
